import socket
from xml.etree import ElementTree
from time import sleep

addr=('<broadcast>',10000)
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET,socket.SO_BROADCAST,1)
s.setblocking(0)

#build xml
root = ElementTree.Element('hdp')
node = root

node = ElementTree.SubElement(node, 'request', {'method':'GET', 'uri':'/conf/machine/net/'})
s0 = ElementTree.tostring(root, 'utf8', 'xml')
print s0

while 1:
    try:
        s.sendto(s0,addr)
        data=s.recvfrom(1024)
        print data[0]
    except socket.error:
        print 'try again'    
        pass
    finally:
        sleep(1)
